package com.tomato.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tomato.entity.TodoSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TodoSettingMapper extends BaseMapper<TodoSetting> {
    /**
     * 根据用户ID查询所有待办设定
     * @param userId 用户ID
     * @return 待办设定列表
     */
    @Select("SELECT * FROM todo_setting WHERE user_id = #{userId} ORDER BY updated_at DESC")
    List<TodoSetting> selectByUserId(@Param("userId") Long userId);

    /**
     * 根据用户ID删除所有待办设定
     * @param userId 用户ID
     * @return 影响行数
     */
    @Select("DELETE FROM todo_setting WHERE user_id = #{userId}")
    Integer deleteByUserId(@Param("userId") Long userId);
}